<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<%
	String path = request.getContextPath();
String foffice = (String)request.getSession().getAttribute("foffice");
%>
<title>血压监测-综合管理</title>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/ext-2.2/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/ext-2.2/style.css" />
<script type="text/javascript"
	src="<%=path%>/ext-2.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/ext-2.2/ext-all.js"></script>
<script type="text/javascript"	src="<%=path%>/ext-2.2/mutlCombox.js"></script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionCharts.js"></script>
	<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionChartsExportComponent.js"></script>
	<script type="text/javascript" src="<%=path%>/js/datepicker/WdatePicker.js" defer="defer"></script>
	<script type="text/javascript" src="<%=path%>/mould_published/public.js" defer="defer"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
	<div id="west-div" style="width: 100%; height: 100%;"></div>
	<div id="center-div"></div>
</body>
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = "<%=path%>/ext-2.2/resources/images/default/s.gif";
	Ext.QuickTips.init();// 为组件提供提示信息功能，form的主要提示信息就是客户端验证的错误信息。
    Ext.form.Field.prototype.msgTarget='side'; 


	Ext.onReady(function() {
				Ext.QuickTips.init();
				
				var foffice_code = "<%=foffice%>"; //机构编码
				
				var Jthtwb = Ext.data.Record.create([ {
					name : 'fpid',
					mapping : 'fpid',
					type : 'string'
				}, {
					name : 'fname',
					mapping : 'fname',
					type : 'string'
				}, {
					name : 'fstate',
					mapping : 'fstate',
					type : 'string'
				}, {
					name : 'fsex',
					mapping : 'fsex',
					type : 'string'
				}, {
					name : 'fphone1',
					mapping : 'fphone1',
					type : 'string'
				}, {
					name : 'fssy',
					mapping : 'fssy',
					type : 'string'
				}, {
					name : 'fszy',
					mapping : 'fszy',
					type : 'string'
				}, {
					name : 'fxl',
					mapping : 'fxl',
					type : 'string'
				}, {
					name : 'fxtnd',
					mapping : 'fxtnd',
					type : 'string'
				}, {
					name : 'fdate',
					mapping : 'fdate',
					type : 'string'
				}, {
					name : 'frdate',
					mapping : 'frdate',
					type : 'string'
				}, {
					name : 'fybkh',
					mapping : 'fybkh',
					type : 'string'
				}  ]);

				var ds = new Ext.data.Store({
					reader : new Ext.data.JsonReader({
						totalProperty : 'totalProperty',
						root : 'root'
					}, Jthtwb),
					idProperty : 'threadid',
					remoteSort : true,
					url : 'xyj!queryXyjRecord.do'
				});

				ds.load( {
					params : {
						start : 0,
						limit : 50,
						fstate : '0',
						fkeywords : '',
						fbtime : '',
						fetime : new Date().format('Y-m-d'),
						foffice : foffice_code,
						fvalueType : '',
						fvalue1 : '',
						fvalue2 : '',
						ftakeBack : '0'
					}
				});


				//定义勾选框，不需要可不必定义
				var sm = new Ext.grid.CheckboxSelectionModel({
					singleSelect : true //单选
				});

				//定义列
				var colM = new Ext.grid.ColumnModel([ sm, new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
				    {
						header : '标记',
						dataIndex : 'fstate',
						width : 40,
						renderer : function(value) {
								if(value == "1") {
									return "<img src='<%=path%>/ext-2.2/icons/flag_blue.png' border=0>";
								} else if(value == "3") {
									return "<img src='<%=path%>/ext-2.2/icons/flag_red.png' border=0>";
								} else {
									//return "<img src='<%=path%>/ext-2.2/icons/flag_blue.png' border=0>";
									return "";
								}
							}
					}, {
						header : '数据接收日期',
						dataIndex : 'frdate',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '医保卡号',
						dataIndex : 'fybkh',
						width : 140,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '身份证号',
						dataIndex : 'fidcd',
						width : 140,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '姓名',
						dataIndex : 'fname',
						width : 80,
						sortable : false
					}, {
						header : '性别',
						dataIndex : 'fsex',
						width : 50,
						renderer : function(value) {
								if (value == "1") {
									return "男";
								} else if (value == "2") {
									return "女";
								} else {
									return "";
								}
							}
					}, {
						header : '年龄',
						dataIndex : 'fage',
						width : 50,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " mmol/L";
								}
							}
					}, {
						header : '手机号码',
						dataIndex : 'fphone1',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '收缩压',
						dataIndex : 'fssy',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /mmHg";
								}
							}
					}, {
						header : '舒张压',
						dataIndex : 'fszy',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /mmHg";
								}
							}
					}, {
						header : '心率',
						dataIndex : 'fxl',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /min";
								}
							}
					} ]);

				
				//生成表格
				var grid = new Ext.grid.GridPanel({
					closable : false,
					region : 'center',
					height : 350,
					autoWidth : true,
					stripeRows : true,
					//title : '角色列表',
					cm : colM,
					ds : ds,
					sm : sm,
					listeners : {
						'rowdblclick' : function(grid, row) { //双击打开
							//var record = grid.getSelectionModel().getSelected();
							//if (record) {
							//	show_chart_fun(record.data.fphone1, record.data.fname);
							//}
						}
					},
					bbar : new Ext.PagingToolbar({
				        pageSize: 50,
				        store: ds,
				        displayInfo: true,
				        displayMsg: '显示 {0} 到 {1} 条记录，共 {2} 条',
				        emptyMsg: "没有记录"
				    })
				});
				
				var b_date = new Ext.form.TextField({
					fieldLabel : '开始日期',
					format: 'yyyy-MM-dd',
					id:'fbtime_id',
					name:'fbdate',
					width : 90,
					style:"cursor:pointer;color:blue",
					listeners : {
						'focus' : function() {
							WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true});
						}
					}
				});
			
	           var e_date = new Ext.form.TextField({
	   				fieldLabel : '结束日期',
	   				format: 'yyyy-MM-dd',
	   				id:'fetime_id',
					name:'fedate',
					width : 90,
					value : new Date().format('Y-m-d'),
	   				style:"cursor:pointer;color:blue",
	   				listeners : {
	   					'focus' : function() {
	   						WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true});
	   					}
	   				}
	   			});
	   			
	   			var btn_search_patient = new Ext.Button({
					text : '查询',
					iconCls : 'sy-search',
					handler : function(btn) {
						ds.removeAll();
						ds.load( {
							params : {
								start : 0,
								limit : 50,
								fstate : fstate_radio.getValue(),
								foffice : foffice_code,
								fkeywords : Ext.get('fkeywords_id').dom.value,
								fbtime : Ext.get('fbtime_id').dom.value,
								fetime : Ext.get('fetime_id').dom.value,
								fvalueType : valueType_radio.getValue(),
								fvalue1 : Ext.get('fvalue1_id').dom.value,
								fvalue2 : Ext.get('fvalue2_id').dom.value,
								ftakeBack : Ext.getCmp('ftakeBack_id').getValue()
							}
						});
					}
				});
				
				var btn_state_blue = new Ext.Button({
					text : '正常',
					iconCls : 'sy-flag_blue',
					handler : function() {
						var record = grid.getSelectionModel().getSelected();
						if (record) {
							Ext.Ajax.request( {
								url : 'xyj!changePatientState.do',
								params:{
				    	        	fpid : record.data.fpid,
				    	        	fstate : '1'
					    	    },
								success : function() {
									ds.reload();
								},
								failure : function() {
									Ext.Msg
											.show( {
												title : '错误提示',
												msg : '设置标记失败！！',
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.ERROR
											});
								}
							});
						} else {
							Ext.MessageBox.alert('提示', '请选择一行纪录进行操作！');
						}
					}
				});
				
				var btn_state_orange = new Ext.Button({
					text : '轻度',
					iconCls : 'sy-flag_orange',
					handler : function() {
						var record = grid.getSelectionModel().getSelected();
						if (record) {
							Ext.Ajax.request( {
								url : 'xyj!changePatientState.do',
								params:{
				    	        	fpid : record.data.fpid,
				    	        	fstate : '2'
					    	    },
								success : function() {
									ds.reload();
								},
								failure : function() {
									Ext.Msg
											.show( {
												title : '错误提示',
												msg : '设置标记失败！！',
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.ERROR
											});
								}
							});
						} else {
							Ext.MessageBox.alert('提示', '请选择一行纪录进行操作！');
						}
					}
				});
				
				var btn_state_red = new Ext.Button({
					text : '中度',
					iconCls : 'sy-flag_red',
					handler : function() {
						var record = grid.getSelectionModel().getSelected();
						if (record) {
							Ext.Ajax.request( {
								url : 'xyj!changePatientState.do',
								params:{
				    	        	fpid : record.data.fpid,
				    	        	fstate : '3'
					    	    },
								success : function() {
									ds.reload();
								},
								failure : function() {
									Ext.Msg
											.show( {
												title : '错误提示',
												msg : '设置标记失败！！',
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.ERROR
											});
								}
							});
						} else {
							Ext.MessageBox.alert('提示', '请选择一行纪录进行操作！');
						}
					}
				});
				
				var btn_list_qy = new Ext.Button({
					text : '获取监测信息',
					iconCls : 'sy-list',
					handler : function() {
						Ext.Ajax.request( {
								url : 'xyj!refreshXyjInfo.do',
								params:{
				    	        	
					    	    },
								success : function() {
									ds.reload();
									
								},
								failure : function() {
									Ext.Msg.show( {
										title : '错误提示',
										msg : '发送失败！！',
										buttons : Ext.Msg.OK,
										icon : Ext.Msg.ERROR
									});
								}
							});
					}
				});

				var btn_send_mess = new Ext.Button({
					text : '发送短信',
					iconCls : 'sy-send-info',
					handler : function() {
					var record = grid.getSelectionModel().getSelected();
						if (record) {
							Ext.Ajax.request( {
								url : 'mess!sendMess.do',
								params:{
				    	        	fphone : record.data.fphone
					    	    },
								success : function() {
									ds.reload();
									Ext.MessageBox.alert(
													'提示',
													'发送成功！');
								},
								failure : function() {
									Ext.Msg.show( {
										title : '错误提示',
										msg : '发送失败！！',
										buttons : Ext.Msg.OK,
										icon : Ext.Msg.ERROR
									});
								}
							});
						} else {
							Ext.MessageBox.alert('提示', '请选择一行纪录进行操作！');
						}
					}
				});
				
				var btn_mess_temp = new Ext.Button({
					text : '短信模板',
					iconCls : 'sy-email_link',
					handler : function() {
					
					
					}
				});
				
				var btn_cancel_qy = new Ext.Button({
					text : '解除签约',
					iconCls : 'sy-delete',
					handler : function() {
						var record = grid.getSelectionModel().getSelected();
						if (record) {
							Ext.Msg.confirm(
								'确认删除','您确定<font color=blue>' + record.data.fname + '</font>解除签约吗？',
								function(btn) {
									if (btn == 'yes') {
										Ext.Ajax.request( {
												url : 'xyj!changeSignState.do',
												params:{
								    	        	fpid : record.data.fpid
									    	    },
												success : function() {
													ds.reload();
													Ext.MessageBox
															.alert(
																	'提示',
																	'成功解除签约！');
												},
												failure : function() {
													Ext.Msg
															.show( {
																title : '错误提示',
																msg : '解除签约失败！！',
																buttons : Ext.Msg.OK,
																icon : Ext.Msg.ERROR
															});
												}
											});
								}
							});

					} else {
						Ext.MessageBox.alert('提示', '请选择一行纪录进行操作！');
						return;
					}
					}
				});
				
				var btn_set_detail = new Ext.Button({
					text : '个性化设置',
					iconCls : 'sy-plugin_edit',
					handler : function() {
						set_detail_fun();
					}
				});
				
				var btn_set_group = new Ext.Button({
					text : '分组维护',
					iconCls : 'sy-group',
					handler : function() {
						
					}
				});


				var panelmenu = new Ext.Panel({
					region: "west",
					split:true,
		            minSize: 105,
		            maxSize: 400,
		            title : '患者信息',
		            collapsible: true,
		            collapsed: true, //展开或关闭
		            margins:'0 0 0 0',
		            layout:'fit',
		            layoutConfig:{
		                animate:true
		            },
					items :[{html : ' '}],
					width:260
			   });
			   
			   var valueType_radio = new Ext.form.RadioGroup({
                       id:'valueType_radio_id',
					   style:'width:100px; display: block;text-align:left;line-height:22px;',
					   height:20,
					   width:180,
       				   fieldLabel : '查询类型',
                       columns : 3,
                       vertical :true,
                       items:[
                              {boxLabel:'收缩压',inputValue:'fssy',name:'fvalueType', checked: true},
                              {boxLabel:'舒张压',inputValue:'fszy',name:'fvalueType'},
                              {boxLabel:'心率',inputValue:'fxl',name:'fvalueType'}
                       ],
				       listeners : {
				        	'change' : function(rg, checked){
				        		valueType_radio.getEl().dom.readOnly = checked.getGroupValue() == 'yes' ? false : true;
					   }}
			    });
			   
			   //取反
			   var takeBack_checkbox = new Ext.form.Checkbox({
	               id:'ftakeBack_id',
	                name:'ftakeBack',   
	                fieldLabel:'是否取反',   
	                boxLabel:'取反',
	                checked:false
	            }); 
	            
				//辅助工具按钮条
				var oneTbar = new Ext.Toolbar({
					items:[ '测量值范围：', {
						xtype : 'numberfield',
						id : 'fvalue1_id',
						name : 'fvalue1',
						style:"cursor:pointer;color:blue",
						width : 80
					}, '<=', valueType_radio, '<=', {
						xtype : 'numberfield',
						id : 'fvalue2_id',
						name : 'fvalue2',
						style:"cursor:pointer;color:blue",
						width : 80
					}, '-', takeBack_checkbox, '-',btn_search_patient, '-', btn_list_qy]
			    });
			    
			    var twoTbar = new Ext.Toolbar({
					items:[ '快发信息：',
						    {
						xtype : 'textarea',
						id : 'fcontent_q_id',
						name : 'fcontent',
						style:"cursor:pointer;color:blue;",
						height : 50,
						width : 500
					}, '-', btn_send_mess , '-', btn_mess_temp 
				    ]
			    });
			    
			    var fstate_radio = new Ext.form.RadioGroup({
			                       id:'ccgc_radio_id',
								   style:'width:100px; display: block;text-align:left;line-height:22px;',
								   height:20,
								   width:170,
			       				   fieldLabel : '标记状态',
			                       columns : 3,
			                       vertical :true,
			                       items:[
			                              {boxLabel:'全部',inputValue:'0',name:'fstate',checked: true},
			                              {boxLabel:'<img src=<%=path%>/extjs/icons/flag_blue.png border=0 title="正常">',inputValue:'1',name:'fstate'},
			                              {boxLabel:'<img src=<%=path%>/extjs/icons/flag_red.png border=0 title="严重超标">',inputValue:'3',name:'fstate'}
			                       ],
							       listeners : {
							        	'change' : function(rg, checked){
							        		fstate_radio.getEl().dom.readOnly = checked.getGroupValue() == 'yes' ? false : true;
								   }}
						    });
			    
			    var panel = new Ext.Panel({
			    	region: "center",
					layout:'fit',
					border : true,
					margins:'0 5 0 0',
					tbar : ['接收日期：',b_date, '至', e_date, '-', '标记：', fstate_radio, '-', '关键字：', {
						xtype : 'textfield',
						fieldLabel : '关键字',
						id : 'fkeywords_id',
						name : 'fkeywords',
						style:"cursor:pointer;color:blue",
						width : 140
					} ],
					listeners : {
						'render' : function(){
							oneTbar.render(this.tbar); 
							twoTbar.render(this.tbar);
						}
				 	},
					items : [ grid]
				});
				
				
				var viewport = new Ext.Viewport({
					layout : 'border',
					items : [ panel ]
				});
			});
</script>


</html>